<template>
  <div class="comment-item">
    <div class="row">
      <div class="left">
        <!-- 载入用户的头像 -->
        <img v-lazy="c_item.userInfo.user_photo" />
        <!-- 用户名称 -->
        <span class="nickName">{{ c_item.userInfo.nickName }}</span>
      </div>
      <div class="right">
        <!-- 过滤时间 -->
        <div>{{ formatDate(c_item.create_time, "YYYY-MM-DD HH:mm:ss") }}</div>
        <div>
          <!-- 五星好评vant的组件 -->
          <rate
            v-model="c_item.star"
            :size="15"
            color="#ffd21e"
            void-icon="star"
            void-color="#eee"
            readonly
          />
        </div>
      </div>
    </div>
    <div class="comment-text">
      {{ c_item.comment_text }}
    </div>
  </div>
</template>

<script>
// 导入过滤器有两种导入方式
import formatDate from "../filters/DateFilter";
// 导入评论的星星
import { Rate } from "vant";
export default {
  name: "CommentItem",
  //   注册
  components: {
    Rate,
  },
  //   从父组件接收变量 c_item
  props: {
    c_item: {
      type: Object,
      require: true,
    },
  },
  setup() {
    return {
      formatDate,
    };
  },
};
</script>

<style lang="scss" scoped>
.comment-item {
  box-sizing: border-box;
  padding: 3px;
  border-bottom: 1px solid #eee;
  .row {
    @include flexbox(row, space-between, center);
    .left {
      @include flexbox(row, flex-start, center);
      img {
        width: 30px;
        height: 30px;
        border-radius: 50%;
        object-fit: cover;
      }
      .inckName {
        margin-left: 5px;
        font-size: 14px;
        line-height: 30px;
        color: #666;
      }
    }
    .right {
      @include flexbox(column, space-between, flex-end);
      font-size: 12px;
    }
  }
  .comment-text {
    line-height: 1.6em;
    font-size: 14px;
    color: rgb(18, 13, 13);
    text-indent: 2em;
  }
}
</style>
